home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Installer SDK 1.2 / Upgrader 1.2.1 & Engines / Upgrader 1.2.1 / Plug-in Examples / SAM Virus Checker Plug-in / Editor Sources / ModalEditorLibMain.cp < prev    next >
Encoding:
Text File  |  1998-08-25  |  3.4 KB  |  92 lines  |  [TEXT/CWIE]

  1.  
  2.  
  3. #include <LApplication.h>
  4. #include <LGrowZone.h>
  5. #include <LWindow.h>
  6. #include <LGroupBox.h>
  7. #include <UMemoryMgr.h>
  8. #include <UDrawingState.h>
  9. #include <URegistrar.h>
  10. #include <UReanimator.h>
  11.  
  12. #include <LEditField.h>
  13. #include <LTabGroup.h>
  14. #include <LCaption.h>
  15. #include <LStdControl.h>
  16. #include <LDialogBox.h>
  17. #include <UModalDialogs.h>
  18. #include <PP_Messages.h>
  19.  
  20. #include "CSAMLauncherEditorWindow.h"
  21. #include "LStyledTextEdit.h"
  22. #include "EditorUtilities.h"
  23. #include "NewWithFree.h"
  24.  
  25. // ===========================================================================
  26. //        • Main Program
  27. // ===========================================================================
  28.  
  29. extern "C" SInt32 main( EditorLibProcParamBlockPtr inEditorLibProcParamBlockPtr )
  30. {
  31.     
  32.     // Assume the worst
  33.     SInt32    result = -1;
  34.  
  35.     try
  36.     {
  37.         // Set Debugging options
  38.         SetDebugThrow_(debugAction_Alert);
  39.         SetDebugSignal_(debugAction_Alert);
  40.  
  41.  
  42.         // Register the shell's QuickDraw globals
  43.         UQDGlobals::SetQDGlobals( inEditorLibProcParamBlockPtr->fQDGlobals );
  44.         
  45.         
  46.         // Setup the menu bar, since the dialog handler expects to enable/disable the Edit menu items.
  47.         //
  48.         // ••• Make sure to use the LMenuBar.cp provided in the SDK, which has smarter LMenuBar::LMenuBar(…) 
  49.         // ••• and LMenuBar::~LMenuBar() routines to support menu handling from within drop-in libraries.
  50.         //
  51.         LMenuBar* theMenuBar = new LMenuBar( MBAR_Initial );
  52.  
  53.  
  54.         // Register some LPane classes.
  55.         URegistrar::RegisterClass(LStyledTextEdit::class_ID,(ClassCreatorFunc) LStyledTextEdit::CreateStyledTextEditStream );
  56.         URegistrar::RegisterClass(LScroller::class_ID,        (ClassCreatorFunc) LScroller::CreateScrollerStream );
  57.         URegistrar::RegisterClass(LEditField::class_ID,        (ClassCreatorFunc) LEditField::CreateEditFieldStream);
  58.         URegistrar::RegisterClass(LTabGroup::class_ID,        (ClassCreatorFunc) LTabGroup::CreateTabGroupStream);
  59.         URegistrar::RegisterClass(LRadioGroup::class_ID,    (ClassCreatorFunc) LRadioGroup::CreateRadioGroupStream );
  60.         URegistrar::RegisterClass(LGroupBox::class_ID,        (ClassCreatorFunc) LGroupBox::CreateGroupBoxStream );
  61.         URegistrar::RegisterClass(LCaption::class_ID,        (ClassCreatorFunc) LCaption::CreateCaptionStream);
  62.         URegistrar::RegisterClass(LStdRadioButton::class_ID,(ClassCreatorFunc) LStdRadioButton::CreateStdRadioButtonStream );
  63.         URegistrar::RegisterClass(LStdCheckBox::class_ID,    (ClassCreatorFunc) LStdCheckBox::CreateStdCheckBoxStream);
  64.         URegistrar::RegisterClass(LStdPopupMenu::class_ID,    (ClassCreatorFunc) LStdPopupMenu::CreateStdPopupMenuStream);
  65.         URegistrar::RegisterClass(LStdButton::class_ID,        (ClassCreatorFunc) LStdButton::CreateStdButtonStream);
  66.         URegistrar::RegisterClass(LDialogBox::class_ID,        (ClassCreatorFunc) LDialogBox::CreateDialogBoxStream);
  67.         URegistrar::RegisterClass(LWindow::class_ID,        (ClassCreatorFunc) LWindow::CreateWindowStream);
  68.  
  69.  
  70.         // Open the editor window and start editing
  71.         if( inEditorLibProcParamBlockPtr->fFileRefNum != -1 )
  72.         { 
  73.             CEditorWindow*    theEditorWindow = new CEditorWindow( inEditorLibProcParamBlockPtr->fFileRefNum, inEditorLibProcParamBlockPtr->fPreferenceRsrcID, inEditorLibProcParamBlockPtr->fResListRsrcID );
  74.             result = theEditorWindow->DoEdit();
  75.             delete theEditorWindow;
  76.         }
  77.         
  78.         delete theMenuBar;
  79.     }
  80.     catch( OSErr theErr )
  81.     {
  82.         ;
  83.     }
  84.     
  85.     // Disposes of memory pools allocated with new operator in order to prevent leaks.
  86.     FreeAllCplusMemory();    
  87.     
  88.     // Return values:  0: Changes accepted, 1: Canceled (changes discarded),  2: Removed,  < 0: Internal error  (changes discarded)
  89.     return result;
  90. }
  91.  
  92.